package com.ruoyi.users.service.impl;

import com.ruoyi.users.dao.StudyPlansContentsDao;
import com.ruoyi.users.domain.StudyPlansContents;
import com.ruoyi.users.service.StudyPlansContentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudyPlansContentsServiceImpl implements StudyPlansContentsService {
    //注入dao
    @Autowired
    private StudyPlansContentsDao repository;
    /**
     * 保存一个内容
     * @param studyPlansContents
     */
    public void saveContent(StudyPlansContents studyPlansContents){
        //如果需要自定义主键，可以在这里指定主键；如果不指定主键，MongoDB会自动生成主键
        repository.save(studyPlansContents);
    }
    /**
     * 更新内容
     * @param studyPlansContents
     */
    public void updateContent(StudyPlansContents studyPlansContents){
        //调用dao
        repository.save(studyPlansContents);
    }
    /**
     * 根据id删除内容
     * @param id
     */
    public void deleteContentById(String id){
        repository.deleteById(id);
    }
    /**
     * 查询所有内容
     * @return
     */
    public List<StudyPlansContents> findContentList(){
        return repository.findAll();
    }
    /**
     * 根据id查询内容
     * @param id
     * @return
     */
    public StudyPlansContents findContentById(String id){

        return repository.findById(id).get();
    }
}
